﻿<?php
//error_reporting(E_ERROR|E_PARSE);
require_once('config.php');
session_start();
if($_SESSION["islogin"]!=='igiveyouthepower'){
echo "<script language=JavaScript>\r\n";
echo "alert('请先登录!');\r\n";
echo "location.href='index.php'\r\n";
echo "</script>";
}else{
$jpwd=$_POST["jpwd"];
$pwd1=$_POST["pwd1"];
$pwd2=$_POST["pwd2"];
if($jpwd==''||$pwd1==''||$pwd2==''){
echo "<script language=JavaScript>\r\n";
echo "alert('请填写完整再提交!');\r\n";
echo "location.href='pwdedit.php'\r\n";
echo "</script>";
exit;
}
if($pwd1!==$pwd2){
echo "<script language=JavaScript>\r\n";
echo "alert('两次新密码输入不一致!');\r\n";
echo "location.href='pwdedit.php'\r\n";
echo "</script>";
exit;
}
$jpwd=$jpwd;
$pwd1=$pwd1;
$conn = mysqli_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname);
$mquery="select * from ph_admin where admin='".$_SESSION["managername"]."' and adminpass='".$jpwd."'";
$mresult=mysqli_query($conn,$mquery);
if(mysqli_num_rows($mresult)<1){
echo "<script language=JavaScript>\r\n";
echo "alert('原密码输入错误!');\r\n";
echo "location.href='pwdedit.php'\r\n";
echo "</script>";
exit;
}
else{
$sql = "update ph_admin set adminpass='".$pwd1."' where admin='".$_SESSION["managername"]."'";
mysqli_query($conn,$sql);
echo "<script language=JavaScript>\r\n";
echo "alert('修改成功!');\r\n";
echo "location.href='pwdedit.php'\r\n";
echo "</script>";
}}
?>